package com.bby.disk.manager.virtual;

import com.bby.common.config.MongoDateConverter;
import com.bby.common.model.Permission;
import com.bby.common.config.MongoIdConverter;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonGetter;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.Id;

import java.io.Serializable;
import java.util.Date;

/**
 * 公共属性
 */
@Data
@Accessors(chain = true)
public class VirtualObject implements Serializable {
    @Id
    @JsonSetter("_id")
    @JsonDeserialize(using = MongoIdConverter.class)
    protected String id;//文件id
    protected String owner;// 文件拥有者
    protected String maker;// 文件建立者
    protected String name;// 文件名
    protected Permission permission;// 文件权限
    @JsonProperty("isFile")
    protected boolean file;// 是文件还是文件夹
    protected String parent;// 父目录
    @JsonFormat( pattern ="yyyy-MM-dd HH:mm:ss", timezone ="GMT+8")
    @JsonDeserialize(using = MongoDateConverter.class)
    protected Date createTime;
    @JsonFormat( pattern ="yyyy-MM-dd HH:mm:ss", timezone ="GMT+8")
    @JsonDeserialize(using = MongoDateConverter.class)
    protected Date lastModified;

    @JsonGetter("id")
    public String getId() {
        return id;
    }
}
